﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Basic_sprite_code
{
    class MagicCircle:Sprite
    {
        public Apprentice caster;

        public int magicAbsorbed;

        public bool summonPresent;

        public MagicCircle(DarkLordsApprentice g, Vector2 position, Apprentice a)
            : base(g, "TestCircle", position, new Vector2(60, 30))
        {
            caster = a;

            magicAbsorbed = 0;
            summonPresent = false;
        }

        public override void Update(GameTime gameTime)
        {
            switch (magicAbsorbed)
            {
                case 0:
                    image = game.Content.Load<Texture2D>("TestCircle");
                    break;

                case 50:
                    image = game.Content.Load<Texture2D>("BigCircleGreen");
                    break;

                case 125:
                    image = game.Content.Load<Texture2D>("BigCircleBlue");
                    break;

                case 200:
                    image = game.Content.Load<Texture2D>("BigCircleRed");
                    break;

                default:
                    break;
            }

            if (!summonPresent)
            {
                if (magicAbsorbed >= 200 && !caster.casting)
                {
                    game.Components.Add(new Dragon(game, caster, new Vector2(425, 600), true, magicAbsorbed - 200));
                    summonPresent = true;
                    
                }
                else if (magicAbsorbed >= 125 && !caster.casting)
                {
                    game.Components.Add(new WindDemon(game, caster, new Vector2(475, 540), true, magicAbsorbed - 125));
                    summonPresent = true;
                    
                }
                else if (magicAbsorbed >= 50 && !caster.casting)
                {
                    game.Components.Add(new Goblin(game, caster, new Vector2(475,540), true, magicAbsorbed - 50));
                    summonPresent = true;
                    
                }
                else if (!caster.casting)
                {
                    magicAbsorbed = 0;
                    summonPresent = false;
                }
            }
            
            base.Update(gameTime);
        }
    }
}
